﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;


namespace CodeCamp.Models.EventMgmt
{
    public class SiteUserEditModel
    {
        public SiteUserEditModel()
        {
            PresenterEvents = new List<EventPresenterViewModel>();
        }
        public int SiteUserId { get; set; }

        /// <summary>
        /// Valid when SiteUserHasMembership is true
        /// </summary>
        public string MemberEmailAddress { get; set; }
        public Nullable<DateTime> MemberCreationDate { get; set; }
        public Nullable<DateTime> MemberLastActivityDate { get; set; }
        public Nullable<DateTime> MemberLastLoginDate { get; set; }
        public bool MemberIsApproved { get; set; }
        public bool MemberIsLockedOut { get; set; }
        public bool MemberIsOnline { get; set; }
        public string MemberUsername { get; set; }
        public bool SiteUserHasMembership { get; set; }

        [Required]
        [MaxLength(128)]
        public string FirstName { get; set; }

        [Required]
        [MaxLength(128)]
        public string LastName { get; set; }

        public string FullName
        {
            get
            {
                string fullName = string.Concat(FirstName, " ", LastName).Trim();
                return fullName;
            }
        }

        [Required]
        [MaxLength(128)]
        public string EmailAddress { get; set; }

        //[Required]
        [MaxLength(256)]
        public string UserIdentityIssuer { get; set; }

        //[Required]
        [MaxLength(256)]
        public string UserIdentityProvider { get; set; }

        /// <summary>
        /// Initially, should be "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
        /// for claims based authentication
        /// </summary>
        //[Required]
        [MaxLength(256)]
        public string UserIdentityClaimType { get; set; }

        //TODO: verify maximum sizes of ClaimType, Claim, other Claims based properties
        /// <summary>
        /// If local ASP.Net Membership provider used, this is the login name
        /// If Claims-based auth, is the property of the claim used for identification,
        /// most probably the value from the nameidentifier claim
        /// </summary>
        //[Required]
        [MaxLength(512)]
        public string UserIdentityClaim { get; set; }

        /// <summary>
        /// Email address provided claims authentication from claims provider.
        /// Value from "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
        /// TODO: Figure out what to do if this changes after this presenter has been created
        /// NOTE: This will be null if auth provider is Live ID
        /// </summary>
        //[MaxLength(128)]
        public string UserClaimEmailAddress { get; set; }

        /// <summary>
        /// Sufficient space for text representation of IP V6
        /// </summary>
        //[MaxLength(50)]
        public string IpAtSignup { get; set; }

        [Required]
        public bool IsApproved { get; set; }

        [Required]
        public bool IsLockedOut { get; set; }

        /// <summary>
        /// Update with logon (using Membership) or postback from claims provider
        /// </summary>
        public Nullable<DateTime> LastLoginUTC { get; set; }

        /// <summary>
        /// Update with each page it to show user online
        /// </summary>
        public Nullable<DateTime> LastOnlineActivityUTC { get; set; }

        /// <summary>
        /// Create a property that can be used in a hidden field 
        /// </summary>
        public byte[] Version { get; internal set; }

        //[Required]
        public DateTime CreatedUTC { get; set; }

        //[Required]
        [MaxLength(128)]
        public string CreatedBy { get; set; }

        public Nullable<DateTime> UpdatedUTC { get; set; }

        [MaxLength(128)]
        public string UpdatedBy { get; set; }

        public bool IsBigCheeze { get; set; }
        public bool IsEventContentEditor { get; set; }
        public bool IsEventTrackLead { get; set; }
        /// <summary>
        /// Note that the Presenter role is set when the user is a presenter at any Code Camp event
        /// and is not specific to this event
        /// </summary>
        public bool IsPresenter { get; set; }
        public bool EventHasNonPublicPreviewRole { get; set; }
        public string NonPublicEventPreviewRole { get; internal set; }
        public bool IsEventPreviewer { get; set; }

        public List<EventPresenterViewModel> PresenterEvents { get; set; }
    }
}